window.onload = function  () {
	//捉图片
	var imgList = document.getElementsByClassName('img_item');

	//捉圆点
	var click_item = document.getElementsByClassName('click_item');
	//捉大区域
	var banner = document.getElementById('banner');
	//捉左点
	var click_left = document.getElementById('click_left');
	//捉右点
	var click_right = document.getElementById('click_right');


	// console.log(imgList);
	// 定义控制图片变量
	var num = 0;
	//执行一次
	function run () {
		//先让所有消失 
		for (var i = 0; i < imgList.length; i++) {
			imgList[i].style.display="none";
			click_item[i].style.background="red";
		};

		//让一个出现
		imgList[num].style.display="block";
		click_item[num].style.background="#fff";

		// 判断最后一个重新来
		if(num==(imgList.length-1)){
			num =0;
		}else{
			num++;
		}
	}

	// 启动定时器
	time = setInterval(run, 1000);

	// 进入大区域让定时器清除 
	banner.onmouseover=function  () {
		clearInterval(time);
	}
	//离开开定时器
	banner.onmouseout=function  () {
		time = setInterval(run, 1000);
	}

	//点击左
	click_left.onclick = function  () {
		num -=2;
		run();
	}

	//点击右
	click_right.onclick = function  () {
		run();
	}

	//循环给每个点给点击事件 
	for (var i = 0; i < click_item.length; i++) {
		// 把下标存储在每个圆点各自的属性上
		click_item[i].xbsindex = i;
		// 循环加点击事件
		click_item[i].onclick = function  () {
			num =this.xbsindex;
			run();
		}
	};

	


























}